﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using com.fukefu.sql;

namespace com.fukefu.tools
{
    public class TitleTag
    {
        List<string> list = new List<string>();
        Random random = new Random();

        public TitleTag()
        {
            Init();
        }
        //初始化
        private void Init()
        {
            SqlServerOperate sql = new SqlServerOperate();
            SqlDataReader re = sql.Query("select * from [全局设置].dbo.[_site_tag]");
            while (re.Read())
            {
                list.Add(re["word"].ToString());
            }
            re.Close();
            sql.Close();
        }
        public string Get()
        {
            return list[random.Next(list.Count)];
        }
        public string Get(int size, string separator)
        {
            string line = "";
            for (int i = 0; i < size; i++)
            {
                line += (line.Equals("") ? "" : separator) + list[random.Next(list.Count)];
            }
            return line;
        }
    }
}
